<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title">文件归档</h4>
        </div>
        <div class="modal-body">
            <form class="modalForm form-horizontal" action="{:url('index/File/addFile')}" method="post">
                <div class="form-body">
                    <div class="form-group">
                        <label class="col-md-3 control-label">待归档文件</label>
                        <div class="col-md-9">
                            <input type="text" readonly class="form-control guidf" placeholder="请输入文件夹名称">
                            <input type="hidden" name="arc_id" class="arc_id">
                            <span class="help-block">选择待归档的文件</span>

                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label">归档到</label>
                        <div class="col-md-9">
                            <input type="text" readonly class="form-control guidp" placeholder="请输入归档到">
                            <input type="hidden" name="interfile_cate_id" class="interfile_cate_id">
                            <span class="help-block">选择归档到的目录</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label">描述</label>
                        <div class="col-md-9">
                            <textarea name="interfile_desc" class="form-control"></textarea>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn default model1close" data-dismiss="modal">关闭</button>
            <button type="button" class="btn blue save">保存</button>
        </div>
    </div>
</div>


<div class="modal fade" id="model2" tabindex="-1" role="model2" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close closeBtn" ></button>
                <h4 class="modal-title">选择归档文件</h4>
            </div>
            <div class="modal-body">
                <div class="portlet green box ">
                    <div class="portlet-title">
                            <a href="javascript:;" onclick="getArc(-1);">部门根目录</a>
                        
                        <div class="caption">
                            <i class="fa fa-cogs"></i>预归档目录
                        </div>
                    </div>
                    <div class="portlet-body">
                        <div id="tree_5" class="tree-demo" style="overflow-x:scroll;">
                            {$tree}
                        </div>
                    </div>
                </div>
                <div class="portlet-body  ">
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-advance table-hover  ">
                            <thead>
                            <tr>
                                <th>
                                    <i class="fa fa-tags"></i> 文件名
                                </th>
                                <th class="hidden-xs">
                                    <i class="fa fa-tag"></i> 创建者
                                </th>
                                <th>
                                    <i class="fa fa-tag"></i> 大小
                                </th>
                                <th>
                                    设置
                                </th>
                            </tr>
                            </thead>
                            <tbody class="tbody" style="text-align: center">

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="model3" tabindex="-1" role="model3" aria-hidden="true" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close closeBtn"></button>
                <h4 class="modal-title">选择归档目录</h4>
            </div>
            <div class="modal-body">
                <div class="portlet green box ">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="fa fa-cogs"></i>归档到
                        </div>
                    </div>
                    <div class="portlet-body">
                        <div id="tree_1" class="tree-demo" style="overflow-x:scroll;">
                            {$tree1}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    App.init();
    UITree.init();
    dt().modalSave();
    $('.closeBtn').click(function () {
        $('#model2').modal('hide');
        $('#model3').modal('hide');
    });
    $('.guidf').click(function () {
        $('#model2').modal('show');
    });
    $('.guidp').click(function () {
        $('#model3').modal('show');
    });
    //进来 预归档根目录文件
    getArc(-1);
    $("#tree_5").on('changed.jstree', function (e, data) {
        var id = data.node.data.id;
        getArc(id);

    });
    $("#tree_1").on('changed.jstree', function (e, data) {
        var id = data.node.data.id;
        $.ajax({
            url:'{:url(\'index/File/getPathById\')}',
            data:{id:id},
            dataType:'json',
            type:'post',
            success:function (e) {
                $('.interfile_cate_id').val(id);
                $('.guidp').val(e.data);
                $('#model3').modal('hide');
            }
        });


    });
    function getArc(id) {
        $.ajax({
            url:'{:url(\'index/File/getArcByCateId\')}',
            data:{id:id},
            dataType:'json',
            type:'post',
            success:function (e) {
                $('.tbody').html(e.data);
                $('.editBtn').click(function () {
                    var aid = $(this).attr('data-id');
                    var aname = $(this).attr('data-name');
                    $('.guidf').val(aname);
                    $('.arc_id').val(aid);
                    $('#model2').modal('hide');
                });
            }
        });
    }
</script>